package br.edu.unibratec.Projeto.view;

import br.edu.unibratec.Projeto.controller.Evento;
import br.edu.unibratec.Projeto.util.AgendadorReceiver;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

public class MostrarActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		TextView txt = new TextView(this);
		txt.setText("Evento Marcado!");
		setContentView(txt);
	}
	
	public void agendarEvento(Evento evento, long newId){
		AlarmManager alarm = (AlarmManager) getSystemService(ALARM_SERVICE);
		Intent it = new Intent(this, AgendadorReceiver.class);
    	it.putExtra("newId", (int)newId);
    	PendingIntent pi = PendingIntent.getBroadcast(this, (int)newId, it, 0);
    	long time = System.currentTimeMillis() + (evento.getData().getTime());
    	alarm.set(AlarmManager.RTC_WAKEUP, time, pi);
	}
	
}
